//
//  ComparisonTableCell.m
//  SecondPage
//
//  Created by winston on 13-4-16.
//  Copyright (c) 2013年 winston. All rights reserved.
//

#import "ComparisonTableCell.h"

@implementation ComparisonTableCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        UIView *tempView = [[[UIView alloc] init] autorelease];
        [self setBackgroundView:tempView];
        [self setBackgroundColor:[UIColor clearColor]];
        
        labelPara= [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 220, 30)];
        labelPara.backgroundColor = [UIColor clearColor];
        labelPara.textAlignment = NSTextAlignmentLeft;
        labelPara.textColor = [UIColor colorWithRed:0.541 green:0.541 blue:0.541 alpha:1.0];
        labelPara.font = [UIFont fontWithName:@"Arial" size:13];
        [self addSubview:labelPara];
        [labelPara release];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)loadData:(ComparisonItem*)data Row:(int)row
{
    [labelPara setText:data.paraValue];

    NSInteger index = 0;
    for(;index<MAXCARCOUNT;index++)
    {
        UILabel * label = (UILabel*)[self viewWithTag:index+100];
        
        if(label==nil)
        {
            CGRect rect;
            if (index == 0) {
                rect = CGRectMake(225, 0, 245, 31);
            }
            else
            {
                rect = CGRectMake(225+255*index, 0, 245, 31);
            }
            
            label = [[UILabel alloc] initWithFrame:rect];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor colorWithRed:0.541 green:0.541 blue:0.541 alpha:1.0];
            
            label.font = [UIFont fontWithName:@"Arial" size:13];
            label.tag = index+100;
            [self addSubview:label];
            [label release];

        }
        if(index<[data.carValueArray count])
        {
            [label setText:[data.carValueArray objectAtIndex:index]];
        }
        else
        {
            [label setText:@""];
        }
        
        if (row%2) {
            [label setBackgroundColor:[UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1.0]];
        }
        else
        {
            [label setBackgroundColor:[UIColor whiteColor]];
        }
    }
}


@end
